<%@page import="com.ym.b2b.cache.configcache.WebAppConfig"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="b" uri="/b2b-tags"%>
<script language="JavaScript" type="text/javascript"
	src="<c:url value="/resources/js/web/tool-tip.js" />"></script>
<link
	href="<c:url value="/views/jsp/product/shoppingcart/css/select.css" />"
	rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript"
	src="<c:url value="/views/jsp/product/shoppingcart/js/jQuery-shopping.js" />"></script>
<script language="JavaScript" type="text/javascript"
	src="<c:url value="/resources/js/web/scroll_search.js" />"></script>

<script>
	setFocus(4);
</script>
<!-- search  begin -->
<div style="margin: 0 auto; width: 1190px;">
	<div class="mianbox">
		<!-- 搜索结果 -->
		<div class="weizhi fl">
			<h2 id="poplogin">首页</h2>
			<span>&gt;</span>
			<h2>
				<a href="<c:url value="/product/searchProduct.s" />">可供品种</a>
			</h2>
			<c:if test="${not empty result.data.svo.productTypeName }">
				<span>&gt;</span>
				<div class="weizhi_ss fl" style="border: none">
					<i> 
						<a href="javascript:searchkeyClose('inc_productTypeCode',2)" style="color: #F50">
							${result.data.svo.productTypeName }
							<img src="<c:url value="/resources/images/product_list/closeSort.png" />">
						</a>
					</i>
				</div>
			</c:if>
			<div class="weizhi_ss fl">
				<input class="txt fl" type="text" id="s_chsName" value="${result.data.svo.chsName }"> 
				<input class="btn fl" type="button" onclick="setChsNameForSearch()">
			</div>
			<div class="tiao fr">
				<font>共找到</font> <font style="color: #8f0100; font-weight: bold;">${result.page.totalRow}</font>
				<font>条相关产品</font>
			</div>
		</div>
		<!-- 搜索结果 -->

		<div class="paixu_xz fl" id="search_condition">
			<div class="paixu_xuanzhe fl">
				<ul>
					<li>
					<a class="<c:choose> <c:when test="${empty result.data.svo.orderByType}">dq</c:when><c:otherwise></c:otherwise> </c:choose>"
						href="javascript:searchProductOrder('')">只显示有库存</a></li>
					<li><a
						class="<c:choose> <c:when test="${result.data.svo.orderByType eq 'ALL'}">dq</c:when><c:otherwise></c:otherwise> </c:choose>"
						href="javascript:searchProductOrder('ALL')"><span></span>显示全部</a></li>
				</ul>

				<div class="ye fr">
					<c:if test="${result.page.page gt  1 }">
						<div class="xia fl">
							<a href="${result.page.pageUrl }&page=${result.page.page-1}">上一页</a>
						</div>
						<a href="${result.page.pageUrl }&page=${result.page.page-1}"
							class="prev"></a>
					</c:if>
					<c:if test="${result.page.totalPage gt result.page.page}">
						<div class="shang fl">
							<a href="${result.page.pageUrl }&page=${result.page.page+1}">下一页</a>
						</div>
					</c:if>
				</div>
				<div class="tiao fr">
					<font>共</font> <font style="color: #ac1d1f;">${result.page.totalRow}</font>
					<font>个商品</font> <font style="margin-left: 14px; display: inline;">${result.page.page}/${result.page.totalPage}</font>
				</div>
			</div>
		</div>
		<form action="<%=request.getContextPath()%>/product/searchProduct.s"
			method="post" name="filterForm" id="filterForm">
			<input type="hidden" id="filterFormSearchWhere" name="searchWhere" value="${result.data.svo.searchWhere}"> 
			<input type="hidden" name="productTypeCode" id="inc_productTypeCode" value="${result.data.svo.productTypeCode}"> 
			<input type="hidden" name="orderByType" id="orderByType" value="${result.data.svo.orderByType}"> 
			<input type="hidden" name="brandId" id="brandId" value="${result.data.svo.brandId}">
		</form>
	</div>

	<!-- search  begin -->
	<div class="mianbox">
		<div id="M-main-b" style="background: white;">
			<c:forEach var="product" items="${result.rows }" varStatus="varstatus">
				<div class="M-main-list" style="width: 1180px;<c:if test="${varstatus.count%2 == '0'}">background: #fafafa;</c:if>">
					<div class="M-main-A left">
						<h3>
							<a
								href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }" onmouseover="javascript:showTip(this, 'roomtip_${varstatus.index}', event);" onmouseout="javascript:hideddrivetip()">
								<p>${product.chsName }</p>
							</a>
						</h3>
					</div>
					<div class="M-main-B left">
						<a
							href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }" onmouseover="javascript:showTip(this, 'roomtip_${varstatus.index}', event);" onmouseout="javascript:hideddrivetip()">
							<p>规格： ${product.productSpec } / ${product.packingUnit }</p>
						</a>
					</div>

					<div class="M-main-D left">
						<a
							href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }">
							<p>生产厂家: ${product.producingName }</p>
						</a>
					</div>
					<div class="M-main-E left">
						<p>
							库存：
							<c:if test="${not empty sessionScope.WEB_USER_TOKEN}">
                        ${product.stockNum} ${product.packingUnit }
                 	</c:if>
							<c:if test="${empty sessionScope.WEB_USER_TOKEN}">
		 			登录查看
					</c:if>
						</p>
					</div>
				</div>

				<!-- 商品扩展信息 -->
                <div id="roomtip_${varstatus.index}"  style="display:none;z-index: 600px;">    
	                   <div style="float: left;width: 260px;background-color:white; color:#fff', '#F26C4F">
	                       <img src="<%=WebAppConfig.getPicPath() %>${product.middlePic}"  width=50% height=50% />
		                   <div><b>药品编号：</b>${product.productCode }</div>    
		                   <div><b>品名：</b>${product.productName }</div>
		                   <div><b>规格：</b>${product.productSpec }</div>
		                   <div><b>单位：</b>${product.packingUnit }</div>
		                   <div><b>生产厂家: </b>${product.producingName }</div>    
		                   <div><b>批准文号/注册证号：</b>${product.authorizeNumber }</div>    
	                   </div>  
                 </div>
                 <!-- 效果div end -->
			</c:forEach>
			<c:import url="/views/jsp/product/import/product_page_info.jsp" />
		</div>
	</div>



	<script type="text/javascript">
		$(function() {
			//分类选中
			if ('${result.data.svo.productTypeCode}' != '') {
				$("#" + '${result.data.svo.productTypeCode}').addClass("sel");
				$("#" + '${result.data.svo.productTypeCode}').attr("href",
						"javascript:searchkeyClose('inc_productTypeCode',2);");
			}
			//分类选中
			if ('${result.data.svo.brandId}' != '') {
				$("#searchBrand a")
						.each(
								function(i) {
									if ($(this).attr("brandId") == '${result.data.svo.brandId}') {
										$(this).addClass("sel");
										$(this)
												.attr("href",
														"javascript:searchkeyClose('brandId',2);");
									}
								});

			}
			//调用shoping加入购物车 效果函数
			$('.Q-buy-btn').shoping();

			//浮动search框
			$("#headerToolbar").smartFloat();

			var topMain = $(".header").height() + $(".weizhi").height()
					+ $(".search_list").height() + $(".mian_search").height()
					+ $(".paixu_xz").height() + 56;
			var topMain2 = $(".header").height() + $(".weizhi").height()
					+ $(".search_list").height() + $(".mian_search").height()
					+ $(".paixu_xz").height() + $(".product_list").height()
					+ 56;
			var nav = $(".nav_scroll");
			$(window).scroll(
					function() {
						if ($(window).scrollTop() > topMain
								&& $(window).scrollTop() < topMain2) {
							nav.css("display", "block");
						} else if ($(window).scrollTop() > topMain2) {
							nav.css("display", "none");
						} else {
							nav.css("display", "none");
						}
					});

		});

		//输入框回车事件
		function addShoppingCartkd13(ob, n) {
			if (event.keyCode == 13) {//回车事件
				$("#buy-s-" + n).click();
			}
		}
		//排序选中--宣城改为库存判断(有库存和全部)
		function searchProductOrder(type) {
			$("#orderByType").val(type);
			$("#filterForm").submit();
		}

		//结果集内搜索
		function setChsNameForSearch() {
			$("#filterFormSearchWhere").val($("#s_chsName").val());
			$("#summary").val($("#s_chsName").val());
			$("#filterForm").submit();
		}
		//关闭搜索条件
		//id form表单的搜索条件  type 搜索类型
		function searchkeyClose(id, type) {
			$("#" + id).val("");
			$("#filterForm").submit();
		}

		function showProduct3d(title, url) {
			$.layer({
				type : 2,
				shadeClose : true,
				title : false,
				closeBtn : [ 0, false ],
				shade : [ 0.8, '#ccc' ],
				border : [ 0 ],
				offset : [ '20px', '' ],
				area : [ '1000px', ($(window).height() - 100) + 'px' ],
				iframe : {
					src : url
				}
			});
		}
	</script>
	<!--内容结束-->
</div>